package com.ddatsh.transaction.client;

import java.util.Date;

import com.ddatsh.transaction.core.model.Request;

/**
 * 请求包工厂实现类
 * 
 * @author ddatsh
 * @version 1.0
 */
public class RequestFactoryImpl implements RequestFactory {
	/**
	 * (non-Javadoc)
	 * 
	 * @see com.ddatsh.transaction.client.RequestFactory#createRequestHeader(java.lang.String,
	 *      java.lang.String)
	 */
	public Request createRequestHeader(String transCode, String channelCode) {
		String requestno = Long.toHexString(System.currentTimeMillis())
				+ String.valueOf(Math.random()).substring(2, 8);

		Request request = new Request();

		request.setRequestNo(requestno);
		request.setChannelCode(channelCode);
		request.setTransCode(transCode);

		request.setRequestTime(new Date());

		request.setTransType(Request.TRANS_TYPE_SYNC);
		request.setStatus(Request.STATUS_INIT);

		return request;
	}
}
